import { ipcMain } from 'electron'
import { createChatWindow } from '../windows/chat'
import { closeLoginWindow } from '../windows/login'

export function setupIpcHandlers() {
  // IPC test
  ipcMain.on('ping', () => console.log('pong'))

  // 登录处理
  ipcMain.on('login', (event, credentials) => {
    const { username, password } = credentials
    const isValid = username === 'admin' && password === '123456'
    
    if (isValid) {
      createChatWindow()
      closeLoginWindow()
    }
    
    event.reply('login-response', isValid)
  })
} 